package com.oazon.moco.link.ui;

import java.util.Arrays;

import com.oazon.moco.link.core.LinkEvent;
import com.oazon.moco.link.core.LinkEventListener;
import com.oazon.moco.link.core.source.LinkEventSource;
import com.oazon.moco.link.event.SystemStatus;
import com.oazon.moco.link.event.SystemStateEvent;

public class SystemStateEventListener extends LinkEventListener {

	public SystemStateEventListener(LinkEventSource... sources) {
		setBlackList(Arrays.asList(sources));
	}

	@Override
	public void onLinkEvent(LinkEvent event) {
		if (filter((LinkEventSource) event.getSource())
				|| !(event instanceof SystemStateEvent)) {
			return;
		}
		SystemStateEvent e = (SystemStateEvent) event;

		if (e.getShutdownToOpenTime() >= 0
				&& e.getWorkStatus().equals(SystemStatus.SHUTDOWN_TO_OPEN_TIME)) {
			shutdownToOpenTime(e.getShutdownToOpenTime());
		} else if (e.getWorkStatus() == SystemStatus.SHUTDONW) {
			shutdown();
		} else if (e.getWorkStatus() == SystemStatus.SHUTDOWN_OPEN_CANCLE) {
			shutdownOpenCancle();
		} else if (e.getWorkStatus() == SystemStatus.WAIT) {
			waite();
		} else if (e.getWorkStatus() == SystemStatus.NORMAL) {
			normal();
		} else if (e.getWorkStatus() == SystemStatus.OPENDOWN) {
			opendown();
		}else if (e.getWorkStatus() == SystemStatus.SCREEN_PROTECT) {
			screenProtect();
		}else if (e.getWorkStatus() == SystemStatus.HAS_ACTION) {
			hasAction();
		}
	}

	/**
	 * 有动作
	 */
	protected void hasAction() {
		
	}

	/**
	 * 进入待机
	 */
	protected void waite() {
		
	}

	/**
	 * 进入屏保
	 */
	protected void screenProtect() {
		
	}

	/**
	 * 开机完成
	 */
	protected void opendown() {
		
	}

	/**
	 * 进入正常状态
	 */
	protected void normal() {
		
	}

	/**
	 * 取消关机
	 */
	protected void shutdownOpenCancle() {
		
	}

	/**
	 * 关机
	 */
	protected void shutdown() {
		
	}

	/**
	 * 关机shutdownToOpenTime时间之后开机
	 * @param shutdownToOpenTime
	 */
	protected void shutdownToOpenTime(int shutdownToOpenTime) {
		
	}
}
